﻿using System;
using System.Collections.Generic;
using Internal.Runtime.Services.Battle;
using Runtime.Services.Battle.Entity;
using Runtime.Services.BattleSkill;

namespace Runtime.Services.Battle {

    /// <summary>
    /// 战斗数据
    /// </summary>
    public interface IDFR_ReadOnlyBattleData : IReadOnlyF64Data {

        new IDFR_BattleData AsReadWrite();

        /// <summary>
        /// 实体ID
        /// </summary>
        public DFR_BattleEntityInstanceID EntityInstanceID { get; }
    }

    /// <summary>
    /// 战斗数据
    /// </summary>
    public interface IDFR_ValueChangedBattleData : IDFR_ReadOnlyBattleData, IValueChangedF64Data {
    }

    /// <summary>
    /// 战斗数据
    /// </summary>
    public interface IDFR_BattleData : IDFR_ValueChangedBattleData, IF64Data {
    }

    [Implement(typeof(IDFR_ReadOnlyBattleData))]
    [Implement(typeof(IDFR_ValueChangedBattleData))]
    [Implement(typeof(IDFR_BattleData))]
    internal sealed class DFR_BattleData : KHBD_Data<F64>, IDFR_BattleData, IDFR_ReadOnlyBattleFusionData.IItem, IDFR_BattleDataInternal {

        public DFR_BattleEntityInstanceID EntityInstanceID { get; private set; }

        protected override void Release() {
            EntityInstanceID = DFR_BattleEntityInstanceID.Empty;
            base.Release();
        }

        void IDFR_BattleDataInternal.EnableFilter(DFR_BattleEntityInstanceID entityInstanceID) {
            EntityInstanceID = entityInstanceID;
        }

        IDFR_BattleData IDFR_ReadOnlyBattleData.AsReadWrite() => this;

        bool IDFR_ReadOnlyBattleFusionData.IItem.IsIgnore(IEnumerable<IDFR_ReadOnlyBattleFusionData.IItem> owner, IReadOnlyCollection<IDFR_ReadOnlyBattleFusionData.IItem> takedItems) {
            return BattleSkillServiceBase.Instance.AsEffectFilter().IsIgnore(owner, this, takedItems);
        }
    }
}

namespace Internal.Runtime.Services.Battle {

    public interface IDFR_BattleDataInternal {

        void EnableFilter(DFR_BattleEntityInstanceID entityInstanceID);
    }
}